package vg.services.graph_view_manager.realization.graph_view.smart_graph_view.realization.actions;

import vg.interfaces.ll_services.data_base_service.data.graph.Edge;
import vg.interfaces.ll_services.data_base_service.data.graph.Vertex;
import vg.services.graph_view_manager.interfaces.graph_view.IGraphRenderer;

import java.util.Collection;

/**
 * Visibility of elements.
 *
 * @author Timur Zolotuhin (e-mail: tzolotuhin@gmail.com)
 */
public class SetVisibleAction extends DefaultActionAdapter {
    // visible action
    public static final int VISIBLE_ACTION = 1;
    // invisible action
    public static final int INVISIBLE_ACTION = 2;

    // Main data
    private int action;

    private Collection<Vertex> vertices;
    private Collection<Edge> edges;

    public SetVisibleAction(int action, Collection<Vertex> vertices, Collection<Edge> edges) {
        super("visible/invisible actions");

        this.action = action;
        this.vertices = vertices;
        this.edges = edges;
    }

    @Override
    public void action(final IGraphRenderer graphRenderer) {
        switch (action) {
            case VISIBLE_ACTION:
                graphRenderer.setVisibleVertices(vertices);
                graphRenderer.setVisibleEdges(edges);
                break;

            case INVISIBLE_ACTION:
                graphRenderer.setInvisibleVertices(vertices);
                graphRenderer.setInvisibleEdges(edges);
                break;

            default:
                break;
        }

        graphRenderer.refreshView();
    }
}
